package com.mars.demo.controller;

import com.mars.demo.model.User;
import com.mars.demo.response.Response;
import com.mars.demo.service.UserFeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@RestController
public class UserController {

    @Resource
    private UserFeignClient userFeignClient;

    @RequestMapping(value = "/userLogin", method = RequestMethod.POST)
    public Response login(String username, String password){
        User user = new User();
        user.setUsername(username);
        user.setPassword(password);
        return Response.success(userFeignClient.login(user));
    }

    @RequestMapping(value = "/testRibbon", method = RequestMethod.GET)
    public Response testRibbon(){
        List<String> results = new ArrayList<String>();
        for (int i = 0; i < 10; i++) {
            String result = userFeignClient.testRibbon(i);
            results.add(result);
        }
        return Response.success(results);
    }

}
